package com.xyht.sca_s.student_manage_system.modules.rxRegistrationChargePayment.controller;


import com.xyht.sca_s.student_manage_system.common.commonReturn.CommonCodeEnum;
import com.xyht.sca_s.student_manage_system.common.commonReturn.CommonResult;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.advanceRegistration.entity.req.SmsAdvanceRegistrationPaymentRecordExportReq;
import com.xyht.sca_s.student_manage_system.modules.rxRegistrationChargePayment.entity.req.RxRegistrationChargePaymentRecordExportReq;
import com.xyht.sca_s.student_manage_system.modules.rxRegistrationChargePayment.service.RxRegistrationChargePaymentRecordService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.concurrent.Future;

/**
 * <p>
 * 缴费记录表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-05-13
 */
@RestController
@RequestMapping("/rxRegistrationChargePayment")
@SecretBody
public class RxRegistrationChargePaymentRecordController {


    @Resource
    private RxRegistrationChargePaymentRecordService rxRegistrationChargePaymentRecordService;

    @ApiOperation("缴费流水记录")
    @GetMapping("/getPaymentRecordList")
    public ResponseResult getPaymentRecordList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                               @RequestParam(value = "planId", required = false) String planId,//计划id
                                               @RequestParam(value = "type", required = false) String type,//招生管理三个应用type
                                               @RequestParam(value = "middleSchoolId", required = false) String middleSchoolId,//初中毕业学校
                                               @RequestParam(value = "majorId", required = false) String majorId,//专业
                                               @RequestParam(value = "startDate", required = false) String startDate,//开始时间
                                               @RequestParam(value = "endDate", required = false) String endDate,//结束时间
                                               @RequestParam(value = "name", required = false) String name,//学生姓名
                                               @RequestParam(value = "isFilingStu", required = false) Integer isFilingStu//学生姓名

    ) {
        return rxRegistrationChargePaymentRecordService.getPaymentRecordList(pageNum, pageSize, planId, type, middleSchoolId, majorId,startDate, endDate,name,isFilingStu);
    }

    @ApiOperation("缴费流水记录导出")
    @PostMapping("/paymentRecords/batch/export")
    public ResponseResult exportStuPaymentInfo(@RequestBody RxRegistrationChargePaymentRecordExportReq exportReq,
                                               HttpServletResponse response) {
        ResponseResult responseResult;
        try {
            Future<ResponseResult> future = rxRegistrationChargePaymentRecordService.exportStuPaymentInfo(exportReq, response);
            while (true) {
                if (future.isDone()) {
                    break;
                }
            }
            responseResult = future.get();
        } catch (Exception e) {
            e.printStackTrace();
            responseResult = CommonResult.failed(CommonCodeEnum.FAIL);
        }
        return responseResult;
    }



}

